<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');
class Base_data_lib {
	function __construct() {
		$this -> CI = &get_instance();
		//log_message('debug', "Login Class Initialized");
	}

	//列出有的人～回傳陣列
	function get_all_users_array() {

		$this -> CI -> load -> model('users_model');
		$AllUsers = $this -> CI -> users_model -> get_all_users();
		$users_array = array();

		foreach ($AllUsers as $key => $val) {
			$users_array[$val -> users_id] = $val -> name;
		}
		return $users_array;
	}
	
	
	//列出有的人～回傳陣列
	function get_all_clients_array() {

		$this -> CI -> load -> model('client_model');
		$AllUsers = $this -> CI -> client_model -> get_all();
		$users_array = array();

		foreach ($AllUsers as $key => $val) {
			$users_array[$val -> client_id] = $val -> name;
		}
		return $users_array;
	}

	//物件類型
	function get_object_usage_array() {

		$this -> CI -> load -> model('object_usage_model');
		$all = $this -> CI -> object_usage_model -> get_all();
		$_array = array();

		foreach ($all as $key => $val) {
			$_array[$val -> object_usage_id] = $val -> value;
		}
		return $_array;
	}

	function get_building_name_array() {

		$this -> CI -> load -> model('building_name_model');
		return $this -> CI -> building_name_model -> get_all_new();

	}

	function get_emphasis_area_array() {

		$this -> CI -> load -> model('emphasis_area_model');
		return $this -> CI -> emphasis_area_model -> get_all_new();

	}

	function get_address_city_array() {

		$this -> CI -> load -> model('address_city_model');
		return $this -> CI -> address_city_model -> get_all_new();
	}

	function get_address_county_array() {

		$this -> CI -> load -> model('address_county_model');
		return $this -> CI -> address_county_model -> get_by_id('1');
	}


	function get_windows_array() {

		$wr_array=array();
		$this -> CI -> load -> model('windows_model');
		$wr =  $this -> CI -> windows_model -> get_all();
		
		foreach($wr as $_k =>$val){			
			$wr_array[$val->windows_id] = $val->value;			
		}

		return $wr_array;
	}
	
	
	function get_parking_type_array() {
		//$_data["parking_type"]  = $this -> parking_type_model   -> get_all();
		$_ar = array();
		$this -> CI -> load -> model('parking_type_model');
		$result=$this -> CI -> parking_type_model -> get_all2();
		
		foreach($result->result() as $val ){
			$_ar[$val->parking_type_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_currency_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('currency_model');
		$result=$this -> CI -> currency_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->currency_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_area_unit_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('area_unit_model');
		$result=$this -> CI -> area_unit_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->area_unit_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_mrt_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('mrt_model');
		$result=$this -> CI -> mrt_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->mrt_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_mrt_line_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('mrt_line_model');
		$result=$this -> CI -> mrt_line_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->mrt_line_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_main_building_array() {
		$_ar = array();
		$this -> CI -> load -> model('main_building_model');
		$result=$this -> CI -> main_building_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->main_building_id]=$val->value;				
		}		
		return $_ar;
	}

	function get_look_mode_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('look_mode_model');
		$result=$this -> CI -> look_mode_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->look_mode_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_use_status_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('use_status_model');
		$result=$this -> CI -> use_status_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->use_status_id]=$val->value;
				
		}
		
		return $_ar;
	}

	
	function get_affiliated_with_array() {
		$_ar = array();
		$this -> CI -> load -> model('affiliated_with_model');
		$result=$this -> CI -> affiliated_with_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->affiliated_with_id]=$val->value;
				
		}
		
		return $_ar;
	}

	
	

	function get_land_use_zoning_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('land_use_zoning_model');
		$result=$this -> CI -> land_use_zoning_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->land_use_zoning_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_object_styles_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('object_styles_model');
		$result=$this -> CI -> object_styles_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->object_styles_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_management_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('management_model');
		$result=$this -> CI -> management_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->management_id]=$val->value;
				
		}
		
		return $_ar;
	}

	function get_required_level_model_array() {
		
		$_ar = array();
		$this -> CI -> load -> model('required_level_model');
		$result=$this -> CI -> required_level_model -> get_all();
		
		foreach($result as $aa=>$val ){
			$_ar[$val->required_level_id]=$val->value;
				
		}
		
		return $_ar;
	}

	//required_level_model

	function collcet_html_show() {
		
		$html = array();

		//$html["currency"]  = $this -> get_currency_array();
		$html["building_name"]  = $this -> get_building_name_array();
		$html["emphasis_area"]  = $this -> get_emphasis_area_array();

		$html["address_city"]   = $this -> get_address_city_array();
		$html["address_county"] = $this -> get_address_county_array();
		return $html;
	}

	function collcet_object_market_ajax() {

		$_array = array();

		$_array["area_unit"]  = $this -> get_area_unit_array();
		$_array["currency"]  = $this -> get_currency_array();
		
		$_array["users"] = 			$this -> get_all_users_array();
		$_array["object_usages"] = 	$this -> get_object_usage_array();

		$_array["look_mode"] = 	$this -> get_look_mode_array();
		$_array["main_building"] = 	$this -> get_main_building_array();
		$_array["use_status"] = 	$this -> get_use_status_array();

		$_array["management"] 		= 	$this -> get_management_array();
		$_array["land_use_zoning"] 	= 	$this -> get_land_use_zoning_array();
		

		$_array["affiliated_with"] 	= 	$this -> get_affiliated_with_array();
		$_array["object_usage"] 	= 	$this -> get_object_usage_array();
		$_array["object_styles"] 	= 	$this -> get_object_styles_array();
		$_array["building_name"] 	=   $this ->get_building_name_array();

		$_array["mrt"] 			= $this  -> get_mrt_array();
		$_array["mrt_line"] 	= $this  -> get_mrt_line_array();


		return $_array;
	}

}

// END Login class
/* End of file Login.php */
